<template>
  <el-link
    :type="linkType"
    :disabled="disabled"
    @click="handleClick"
  >
    {{ linkLabel }}
  </el-link>
</template>
<script>
import { getCompleteStatusStr } from '../../latentProduct/utils';
import { COMMON_IMAGE_STATUS_ENUMS } from '@/constants/commodity';
export default {
  props: {
    completeStatus: {
      type: String | Number,
      default: ''
    },
    isComplete: {
      type: Boolean
    },
    disabled: {
      type: Boolean,
      default: false
    }
  },
  computed: {
    linkLabel () {
      const getStatusByConvertBool = () => this.isComplete
        ? COMMON_IMAGE_STATUS_ENUMS.Completed
        : COMMON_IMAGE_STATUS_ENUMS.Incomplete
      const status = this.completeStatus ? this.completeStatus : getStatusByConvertBool()
      const label = getCompleteStatusStr(String(status))
      return label
    },
    linkType () {
      const status = String(this.completeStatus)
      if (status == COMMON_IMAGE_STATUS_ENUMS.Completed || this.isComplete) return 'success'
      return 'primary'
    }
  },
  methods: {
    // 点击
    handleClick () {
      this.$emit('click')
    }
  }
}
</script>
<style lang="less" scoped>
/deep/ .el-link--inner {
  font-size: 12px;
}
</style>
